const router = require('koa-router')()
const USER = require('../models/users')
const GOODS = require('../models/goods')
const ORDER = require('../models/order')

router.get('/', async (ctx, next) => {
  await USER.create({id:123,name:"xiam"})
  await GOODS.create({title:"商品类型",size:['大','小']})
  await ORDER.create({goods:['商品1','商品2'],price:10})
  await ctx.render('index', {
    title: 'Hello Koa 2!'
  })
})

router.get('/string', async (ctx, next) => {
  ctx.body = 'koa2 string'
})

router.get('/json', async (ctx, next) => {
  ctx.body = {
    title: 'koa2 json'
  }
})

module.exports = router
